/*
 * This file is part of qmsystem-qml-example package
 *
 * Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to 
 * deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,     
 * and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER  
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS  
 * IN THE SOFTWARE. 
 */

import QtQuick 1.1
import com.nokia.meego 1.0


/*!
 * @brief Custom page header component
 *
 * Page header is an area used for title of the current page.
 * It contains background image and text element.
 */
Image {
    id: headerholder

    property string text : ""

    //! Height of header is different for landscape and portrait orientation
    height: parent.width < parent.height ? UiConstants.HeaderDefaultHeightPortrait : UiConstants.HeaderDefaultHeightLandscape
    width: parent.width
    source: "image://theme/meegotouch-view-header-fixed" + (theme.inverted ? "-inverted" : "")

    //! Page header should be on top of the page. Increasing z value.
    x: 0; y: 0; z: parent.z + 1

    //! Header container
    Item {
        anchors.fill: parent

        //! Different margins apply for portrait and landscape orientation
        anchors.topMargin: parent.width < parent.height ? UiConstants.HeaderDefaultTopSpacingPortrait : UiConstants.HeaderDefaultTopSpacingLandscape
        anchors.bottomMargin: parent.width < parent.height ? UiConstants.HeaderDefaultBottomSpacingPortrait : UiConstants.HeaderDefaultBottomSpacingLandscape
        anchors.rightMargin: UiConstants.DefaultMargin
        anchors.leftMargin: UiConstants.DefaultMargin

        //! Page header text
        Label {
            id: header
            anchors { verticalCenter: parent.verticalCenter; left: parent.left }
            font { family: UiConstants.HeaderFont.family; weight: UiConstants.HeaderFont.weight; pixelSize: UiConstants.HeaderFont.pixelSize }
            text: headerholder.text

            //! Setting text color based on page theme
            color:  UiConstants.FieldLabelColor
        }
    }
}

//! End of file
